package io.homework2;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;

public class Test3 {
    public static void main(String[] args) throws Exception {
        FileOutputStream fos = new FileOutputStream("hw1.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);

        osw.write("针不戳呀针不戳");
        System.out.println("字符写出完成");
        osw.close();


        FileInputStream fis = new FileInputStream("hw1.txt");
        InputStreamReader isr = new InputStreamReader(fis,StandardCharsets.UTF_8);

        int r;
        while ((r=isr.read())!=-1){
            System.out.print((char) r);
        }
        System.out.println();
        System.out.println("读入成功");
        isr.close();


    }
}
